﻿#include <ctime>
#include <iostream>
using namespace std;
void BubbleSort(int list[], int listLen) {
	while (listLen--) {
		bool sw = false;
		for (int i = 0; i < listLen; i++) {
			if (list[i] > list[i + 1]) {
				swap(list[i], list[i + 1]);
				sw = true;
			}
		}
		if (sw = false) {
			break;
		}
	}
}
void read_file(const char* filename, int a[], int length) {
	ifstream file(filename);
	for (int i = 0; i < length; i++)
		file >> a[i];
}
int main() {
#define LEN 5000
	int a[LEN];

	read_file("m1_sorted.txt", a, LEN);
	int t_start = clock();
	BubbleSort(a, LEN);
	int t_end = clock();
	cout << (t_end - t_start);

	read_file("m2_reverse.txt", a, LEN);
	int t_start = clock();
	BubbleSort(a, LEN);
	int t_end = clock();
	cout << (t_end - t_start);

	read_file("m3_shuffle.txt", a, LEN);
	int t_start = clock();
	BubbleSort(a, LEN);
	int t_end = clock();
	cout << (t_end - t_start);

	return 0;
}